package consts

var (
	FavoritesNotExistNotify = "notify"
	FavoritesNotExistDelete = "delete"
	FavoritesNotExistIgnore = "ignore"
	FavoritesNotExistAction = NewPairs(map[string]string{
		FavoritesNotExistNotify: "每次通知",
		FavoritesNotExistDelete: "自动删除",
		FavoritesNotExistIgnore: "忽略",
	})
)

type Pairs struct {
	KV   map[string]string
	VK   map[string]string
	size int
}

func (p Pairs) GetValues() []string {
	values := make([]string, 0, p.size)
	for v := range p.VK {
		values = append(values, v)
	}
	return values
}

func (p Pairs) GetKeys() []string {
	keys := make([]string, 0, p.size)
	for k := range p.KV {
		keys = append(keys, k)
	}
	return keys
}

func (p Pairs) GetValue(key string) string {
	return p.KV[key]
}

func (p Pairs) GetKey(value string) string {
	return p.VK[value]
}

func NewPairs(kv map[string]string) Pairs {
	p := Pairs{KV: kv, size: len(kv)}
	p.VK = make(map[string]string)
	for k, v := range kv {
		p.VK[v] = k
	}
	return p
}
